package cn.wolfcode.restful.util;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Setter@Getter
@NoArgsConstructor
public class JsonResult {

    private int code;       //状态码
    private String msg;     //状态信息
    private Object data;    //返回的参数

    public JsonResult(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    //返回一个状态码
    public static JsonResult success(){
        return new JsonResult(200,"操作成功",null);
    }

    //要返回的参数
    public static JsonResult success(Object data){
        return new JsonResult(200,"操作成功",data);
    }

    //出错处理
    public static JsonResult success(String msg){
        return new JsonResult(500,msg,null);
    }

}
